#pragma once
#ifndef __CAMERA_H__
#define __CAMERA_H__

#include "Utility.h"

#include "../util/D3DCommon.h"
#include "../util/PreDeclare.h"
#include "Component.h"

namespace WindGE
{
	class WIND_CORE_API Camera : public Component
	{
	public:
		Camera();
		Camera(GameObjectPtr gameObject);
		virtual ~Camera() {}

		inline XMMATRIX view_matrix() const	{ return XMLoadFloat4x4(&view_matrix_); }
		inline XMMATRIX proj_matrix() const	{ return XMLoadFloat4x4(&proj_matrix_); }

		inline const XMFLOAT3& position() const	{ return position_; }
		inline void set_position(const XMFLOAT3& pos) { position_ = pos; }
		
		inline const XMFLOAT3& target() const	{ return target_; }

		inline void set_proj_matrix(float filedOfView, float aspectRatio, float nearPlane, float farPlane)
		{
			XMMATRIX P = XMMatrixPerspectiveFovLH(filedOfView, aspectRatio, nearPlane, farPlane);
			XMStoreFloat4x4(&proj_matrix_, P);
		}

		void update();

	protected:
		virtual void update_view_matrix();

	protected:
		XMFLOAT3	position_;
		XMFLOAT3	target_;

		XMFLOAT3	look_;
		XMFLOAT3	up_;
		XMFLOAT3	right_;

		XMFLOAT4X4	view_matrix_;
		XMFLOAT4X4	proj_matrix_;

	protected:
		FrustumPtr	frustum_;
	};
}

#endif // !__CAMERA_H__


